import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import monkey, { cdn, util } from 'vite-plugin-monkey';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    monkey({
      entry: 'src/main.ts',
      userscript: {
        name: "联通内网 - 联通党校",
        icon: 'https://unicom.studio/Unicom.svg',
        namespace: 'npm/vite-plugin-monkey',
        author: "easterNday",
        description: '创新学习，强国有我 - 联通党校课程管理系统',
        license: 'MIT',
        match: [
          'https://campus.chinaunicom.cn/training/pc/*',
          'https://ict.chinaunicom.cn:8000/frm/main'
        ],
      },
      build: {
        externalGlobals: {
          vue: cdn.jsdelivr('Vue', 'dist/vue.global.prod.js')
            .concat(util.dataUrl(';window.Vue=Vue;')),
          'element-plus': cdn.unpkg('ElementPlus', 'dist/index.full.min.js'),
          // 'crypto-js': cdn.unpkg('crypto-js', 'crypto-js.js'),
          // "jsencrypt": cdn.jsdelivr('nodejs-jsencrypt', 'bin/jsencrypt.min.js'),
        },
        externalResource: {
          "element-plus/dist/index.css": cdn.unpkg('elementPlusCss', "dist/index.css")
        },
      },
      server: { mountGmApi: true },
    }),
  ],
});
